package org.pentaho.streaming.autotask;

import org.pentaho.di.core.ObjectLocationSpecificationMethod;
import org.pentaho.di.core.annotations.Step;
import org.pentaho.di.core.injection.Injection;
import org.pentaho.di.core.injection.InjectionSupported;
import org.pentaho.di.core.row.RowMeta;
import org.pentaho.di.core.row.value.ValueMetaString;
import org.pentaho.di.core.variables.VariableSpace;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.StepDataInterface;
import org.pentaho.di.trans.step.StepInterface;
import org.pentaho.di.trans.step.StepMeta;
import org.pentaho.di.trans.step.StepMetaInterface;
import org.pentaho.di.trans.streaming.common.BaseStreamStepMeta;

import static org.pentaho.streaming.autotask.AutoTaskConstants.DATE_AT;

@Step(
        id = "AutoTaskConsumer", image = "AutoTaskConsumer.svg",
        i18nPackageName = "pentaho.streaming.autotask",
        name = "AutoTaskConsumer.TypeLongDesc",
        description = "AutoTaskConsumer.TypeTooltipDesc",
        categoryDescription = "i18n:org.pentaho.di.trans.step:BaseStep.Category.Streaming"
)
@InjectionSupported(localizationPrefix = "AutoTaskConsumerMeta.Injection.", groups = {"SSL"})
public class AutoTaskConsumerMeta extends BaseStreamStepMeta implements StepMetaInterface {
    private static final Class<?> PKG = AutoTaskConsumerMeta.class;

    @Injection(name = DATE_AT)
    private String dateAt = "DATE_AT";

    public AutoTaskConsumerMeta() {
        super();
        setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
    }

    public String getDateAt() {
        return dateAt;
    }

    public void setDateAt(String dateAt) {
        this.dateAt = dateAt;
    }

    public void setDefault() {
        super.setDefault();
    }

    @Override
    public String getFileName() {
        return getTransformationPath();
    }


    @Override
    public RowMeta getRowMeta(String origin, VariableSpace space) {
        RowMeta rowMeta = new RowMeta();
        rowMeta.addValueMeta(new ValueMetaString(dateAt));
        return rowMeta;
    }

    public StepInterface getStep(StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
                                 Trans trans) {
        return new AutoTaskConsumer(stepMeta, stepDataInterface, cnr, tr, trans);
    }

    public StepDataInterface getStepData() {
        return new AutoTaskConsumerData();
    }

    @SuppressWarnings({"deprecation"})
    // can be removed once the new @PluginDialog annotation supports OSGi
    public String getDialogClassName() {
        return "org.pentaho.streaming.autotask.AutoTaskConsumerDialog";
    }

//    @Override
//    public boolean equals(Object o) {
//        if (this == o) {
//            return true;
//        }
//        if (o == null || getClass() != o.getClass()) {
//            return false;
//        }
//        AutoTaskConsumerMeta that = (AutoTaskConsumerMeta) o;
//        return Objects.equals(dateAt, that.dateAt);
//    }
//
//    @Override
//    public int hashCode() {
//        return Objects.hash(dateAt);
//    }

    @Override
    public AutoTaskConsumerMeta copyObject() {
        return (AutoTaskConsumerMeta) this.clone();
    }
}
